package org.zerocouplage.component.impl.config;

import org.zerocouplage.component.api.component.ZCComponent;
import org.zerocouplage.component.api.config.IZCTemplateConfig;

public class ZCTemplateConfigImpl implements IZCTemplateConfig {

	private String content;
	private ZCComponent component;

	public ZCTemplateConfigImpl() {

	}

	public ZCComponent getComponent() {
		return component;
	}

	public void setComponent(ZCComponent component) {
		this.component = component;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public void replace(String key, Object value) {
		if (value instanceof ZCComponent) {
			content.replaceAll("$" + key + "$", component.display().toString());
		} else {
			content.replaceAll("$" + key + "$", value.toString());
		}
	}

}
